﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GPCSC.Webs;
using System.Collections;
using System.Data;
using NickLee.Common;
using HSYCDomain;

namespace HSYCWeb.web.DOCS
{
    public partial class NewRczc : HSYCWeb.Common.PageBase
    {
        public string imgurl = "Unull.gif";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //人员表GJRC 的主键值

                byte[] userInfo = (byte[])base.o_baseTable[c_obj.s_userInfo];
                GJRC user = new GJRC();
                if (userInfo.Length != 0)
                {
                    Hashtable userInfoTable = CompressData.UnCompressHashtable(userInfo);
                    user = (GJRC)userInfoTable["GJRC"];

                }
                this.MtxtD_RCID.Value = user.RCID.ToString();

                string state = user.STATE.ToString();

                //验证后填写信息
                if (state == "4")
                {
                    this.addxx.Style.Add("display","");
                    this.edtxx.Style.Add("display","none");
                    this.reemail.Style.Add("display", "none");
                    ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>afterlo('4');</script>");
                }
                //提交信息后进行修改
                else if(state =="0")
                {
                    this.addxx.Style.Add("display", "none");
                    this.edtxx.Style.Add("display", "");
                    this.reemail.Style.Add("display", "none");
                    F_loadbund();//初始化人员信息
                    F_loadsfbund();//初始化绑定照片信息
                    F_loadtxbund();//头像
                    JLlists();//工作经历
                    ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>afterlo('0');</script>");
                }
                //审核通过
                else if (state == "1")
                {
                    this.addxx.Style.Add("display", "none");
                    this.edtxx.Style.Add("display", "");
                    this.reemail.Style.Add("display", "none");
                    F_loadbund();//初始化人员信息
                    F_loadsfbund();//初始化绑定照片信息
                    F_loadtxbund();//头像
                    JLlists();//工作经历
                    ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>afterlo('1');</script>");
                }
                //尚未验证
                else if (state == "3")
                {
                    
                    this.addxx.Style.Add("display", "none");
                    this.edtxx.Style.Add("display", "none");
                    this.reemail.Style.Add("display","");
                    F_loadbund();//初始化人员信息
                    ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>afterlo('3');</script>");
                }
                //审核未通过
                else if (state == "5")
                {

                    this.addxx.Style.Add("display", "none");
                    this.edtxx.Style.Add("display", "");
                    this.reemail.Style.Add("display", "none");
                    F_loadbund();//初始化人员信息
                    F_loadsfbund();//初始化绑定照片信息
                    F_loadtxbund();//头像
                    JLlists();//工作经历
                    ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>afterlo('5');</script>");
                }
            }
            
        }

        #region   填写注册信息表
        /// <summary>
        /// 工作经历列表
        /// </summary>
        protected void JLlist()
        {
            Hashtable htbale = new Hashtable();
            DataSet ds = new DataSet();
            htbale.Add("@RCID_P",this.MtxtD_RCID.Value);
            ds = new SqlReadXml().ReaderDataSet("sel_userJLlist_all", htbale);
            //if (ds.Tables[0].Rows.Count > 0)
            //{ 
            //    foreach()
            //}
            Repeater1.DataSource = ds;
            Repeater1.DataBind();
            
           
        }
        /// <summary>
        /// 照片列表
        /// </summary>
        /// <param name="state"></param>
        /// <returns></returns>
        protected DataSet zplist(string state)
        {
            Hashtable htable = new Hashtable();
            htable.Add("@state", Usual.f_convertInt32(state));
            htable.Add("@GJRCId", this.MtxtD_RCID.Value);
            DataSet ds = new SqlReadXml().ReaderDataSet("sel_userGJRCFile_all", htable);
            return ds;
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                saveRC();

            }
            catch (Exception ee)
            {
                throw ee;
            }
        }
        /// <summary>
        /// 保存录入信息
        /// </summary>
        protected void saveRC()
        {
            Hashtable htable = f_getElements();
            GPCSC.Webs.databyhtable dtable = new GPCSC.Webs.databyhtable();
            dtable.databyhtables(base.o_uiTable, "update", "GJRC", "RCID", this.MtxtD_RCID.Value.Trim());

            this.Response.Write("<script>alert('添加成功！');</script>");
        }
        public Hashtable f_getElements()
        {
            base.o_uiTable.Clear();
            base.o_uiTable = GPCSC.Webs.UIFactory.UIFactory_Get(this);
            base.o_uiTable.Add("STATE", 0);
            base.o_uiTable.Add("txdate", DateTime.Now);
            return base.o_uiTable;
        }
        /// <summary>
        /// 工作经历操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void LCall_Callback(object sender, NickLee.Web.UI.CallBackEventArgs e)
        {
            try
            {
                string type = e.Parameters[0].ToString();
                #region 增加人员工作经历信息
                if (type == "add")
                {
                    string kdate = e.Parameters[1].ToString();
                    string jdate = e.Parameters[2].ToString();
                    string dwxi = e.Parameters[3].ToString();
                    string bezw = e.Parameters[4].ToString();
                    string RCID_P = this.MtxtD_RCID.Value;
                    Hashtable htable = new Hashtable();
                    htable.Add("RCID_P", RCID_P);
                    htable.Add("kdate", kdate);
                    htable.Add("jdate", jdate);
                    htable.Add("gxname", dwxi);
                    htable.Add("zhiwu", bezw);
                    GPCSC.Webs.databyhtable dtable = new GPCSC.Webs.databyhtable();
                    dtable.databyhtables(htable, "add", "XGJL", "", "");
                    JLlist();
                    Panel1.RenderControl(e.Output);
                }
               
                #endregion

                #region 删除人员工作经历
                else if (type == "del")
                {
                    string jlid = e.Parameters[1].ToString();
                    Hashtable htable = new Hashtable();
                    htable.Add("IsDel",1);
                    GPCSC.Webs.databyhtable dtable = new GPCSC.Webs.databyhtable();
                    dtable.databyhtables(htable, "update", "XGJL", "tabid", jlid);
                    JLlist();
                    Panel1.RenderControl(e.Output);
                }
              
                #endregion




            }
            catch (Exception ee)
            {
                throw ee;
            }
            finally
            {
               
            }
        }
        /// <summary>
        /// 身份证照片操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        protected void CallBack1_Callback(object sender, NickLee.Web.UI.CallBackEventArgs e)
        {
            string type = e.Parameters[0].ToString();
            if (type == "add")
            {
                Repeater2.DataSource = zplist("0");
                Repeater2.DataBind();
                Panel2.RenderControl(e.Output);
            }
            else if (type == "del")
            {
                string jlid = e.Parameters[1].ToString();
                Hashtable htable = new Hashtable();
                htable.Add("Isdel", 1);
                GPCSC.Webs.databyhtable dtable = new GPCSC.Webs.databyhtable();
                dtable.databyhtables(htable, "update", "GJRCFile", "RCFileid", jlid);
                Repeater2.DataSource = zplist("0");
                Repeater2.DataBind();
                Panel2.RenderControl(e.Output);
               
            }

        }
        /// <summary>
        /// 头像操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void CallBack2_Callback(object sender, NickLee.Web.UI.CallBackEventArgs e)
        {
            string type = e.Parameters[0].ToString();
            if (type == "add")
            {
                Repeater3.DataSource = zplist("1");
                Repeater3.DataBind();
                Panel3.RenderControl(e.Output);
            }
            else if (type == "del")
            {
                string jlid = e.Parameters[1].ToString();
                Hashtable htable = new Hashtable();
                htable.Add("Isdel", 1);
                GPCSC.Webs.databyhtable dtable = new GPCSC.Webs.databyhtable();
                dtable.databyhtables(htable, "update", "GJRCFile", "RCFileid", jlid);
                Repeater3.DataSource = zplist("1");
                Repeater3.DataBind();
                Panel3.RenderControl(e.Output);
                
            }
 
        }

        #endregion

        #region  修改注册信息表

        /// <summary>
        /// 初始化绑定 页面赋值
        /// </summary>
        protected void F_loadbund()
        {
            string RCID = this.MtxtD_RCID.Value;
            DataSet ds = new DataSet();
            Hashtable htable = new Hashtable();
            htable.Add("@RCID", RCID);
            ds = new SqlReadXml().ReaderDataSet("sel_userRCID_one", htable);
            UIFactory.UIFactory_Set(this, ds.Tables[0]);        

        }
        //初始化绑定身份照片
        protected void F_loadsfbund()
        {
            string RCID = this.MtxtD_RCID.Value;
            DataSet ds = new DataSet();
            Hashtable htable = new Hashtable();
            htable.Add("@GJRCId", RCID);
            htable.Add("@state", 0);
            ds = new SqlReadXml().ReaderDataSet("sel_userGJRCFile_all", htable);
            Repeater5.DataSource = ds;
            Repeater5.DataBind();
        }
        protected void F_loadtxbund()
        {
            string RCID = this.MtxtD_RCID.Value;
            DataSet ds = new DataSet();
            Hashtable htable = new Hashtable();
            htable.Add("@GJRCId", RCID);
            htable.Add("@state", 1);
            ds = new SqlReadXml().ReaderDataSet("sel_usertx_new", htable);
            if (ds != null)
            {
                if (ds.Tables.Count > 0)
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        imgurl = ds.Tables[0].Rows[0]["fileUrl"].ToString();
                    }
                }
            }
        }
        protected void CallBack3_Callback(object sender, NickLee.Web.UI.CallBackEventArgs e)
        {
            try
            {
                string type = e.Parameters[0].ToString();
                #region 增加人员工作经历信息
                if (type == "add")
                {
                    string kdate = e.Parameters[1].ToString();
                    string jdate = e.Parameters[2].ToString();
                    string dwxi = e.Parameters[3].ToString();
                    string bezw = e.Parameters[4].ToString();
                    string RCID_P = this.MtxtD_RCID.Value;
                    Hashtable htable = new Hashtable();
                    htable.Add("RCID_P", RCID_P);
                    htable.Add("kdate", kdate);
                    htable.Add("jdate", jdate);
                    htable.Add("gxname", dwxi);
                    htable.Add("zhiwu", bezw);
                    GPCSC.Webs.databyhtable dtable = new GPCSC.Webs.databyhtable();
                    dtable.databyhtables(htable, "add", "XGJL", "", "");
                    JLlists();
                    Panel4.RenderControl(e.Output);
                }

                #endregion

                #region 删除人员工作经历
                else if (type == "del")
                {
                    string jlid = e.Parameters[1].ToString();
                    Hashtable htable = new Hashtable();
                    htable.Add("IsDel", 1);
                    GPCSC.Webs.databyhtable dtable = new GPCSC.Webs.databyhtable();
                    dtable.databyhtables(htable, "update", "XGJL", "tabid", jlid);
                    JLlists();
                    Panel4.RenderControl(e.Output);
                }

                #endregion
            }
            catch (Exception ee)
            {

            }
            finally
            { 
            
            }
        }

        /// <summary>
        /// 工作经历列表
        /// </summary>
        protected void JLlists()
        {
            Hashtable htbale = new Hashtable();
            DataSet ds = new DataSet();
            htbale.Add("@RCID_P", this.MtxtD_RCID.Value);
            ds = new SqlReadXml().ReaderDataSet("sel_userJLlist_all", htbale);
            //if (ds.Tables[0].Rows.Count > 0)
            //{ 
            //    foreach()
            //}
            Repeater4.DataSource = ds;
            Repeater4.DataBind();


        }
        #endregion

        protected void CallBack4_Callback(object sender, NickLee.Web.UI.CallBackEventArgs e)
        {
            string type = e.Parameters[0].ToString();
            if (type == "add")
            {
                Repeater5.DataSource = zplist("0");
                Repeater5.DataBind();
                Panel5.RenderControl(e.Output);
            }
            else if (type == "del")
            {
                string jlid = e.Parameters[1].ToString();
                Hashtable htable = new Hashtable();
                htable.Add("Isdel", 1);
                GPCSC.Webs.databyhtable dtable = new GPCSC.Webs.databyhtable();
                dtable.databyhtables(htable, "update", "GJRCFile", "RCFileid", jlid);
                Repeater5.DataSource = zplist("0");
                Repeater5.DataBind();
                Panel5.RenderControl(e.Output);

            }
        }

        protected void CallBack5_Callback(object sender, NickLee.Web.UI.CallBackEventArgs e)
        {
            string type = e.Parameters[0].ToString();
            if (type == "add")
            {
                F_loadtxbund();
                Panel6.RenderControl(e.Output);
            }
          
        }



        #region  重新发送验证邮件
        protected void Button3_Click(object sender, EventArgs e)
        {
            GPCSC.Webs.SendEmail se = new SendEmail();
            string sjEmail = this.DOHCDSEmaile.Text.Trim();
            se.sendMails("mayawei890102@163.com", sjEmail, "http://192.168.1.89/haycw/web/DOCS/qrze.aspx?id=" + this.MtxtD_RCID.Value.ToString(), "测试", "mayawei890102", "wwyawei", "");
            this.Response.Write("<script>alert('邮件发送成功！');</script>");
        }
        #endregion

        #region 重新提交
        protected void Button4_Click(object sender, EventArgs e)
        {
            Hashtable htable = new Hashtable();
            htable.Add("STATE",0);
            GPCSC.Webs.databyhtable dtable = new GPCSC.Webs.databyhtable();
            dtable.databyhtables(htable, "update", "GJRC", "RCID", this.MtxtD_RCID.Value.Trim());
            this.Response.Write("<script>alert('提交成功！');</script>");
        }
        #endregion



    }
}